{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b35d2e8f",
   "metadata": {},
   "source": [
    "# 指定特征文件\n",
    "\n",
    "* save2： 修改成自己保存的特征目录\n",
    "* feature_files：要融合的特征的特征文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3ddc852",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from IPython.display import display\n",
    "os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'\n",
    "from onekey_algo import OnekeyDS as okds\n",
    "import pandas as pd\n",
    "from onekey_algo.custom.components.comp1 import merge_results\n",
    "\n",
    "os.makedirs('img', exist_ok=True)\n",
    "os.makedirs('results', exist_ok=True)\n",
    "os.makedirs('features', exist_ok=True)\n",
    "save2 = r'features/combined_features.csv'\n",
    "# 设置数据目录\n",
    "# label_file = r'你自己数据的路径'\n",
    "feature_files = [r'C:/Users/onekey/Desktop/demo/20250328/code/results/AdaBoost_Rad_train.csv', \n",
    "                 r'C:/Users/onekey/Desktop/demo/20250328/code/results/LR_Rad_train.csv',\n",
    "                 r'C:/Users/onekey/Desktop/demo/20250328/code/results/MLP_Rad_train.csv']\n",
    "data = [pd.read_csv(feature_file) for feature_file in feature_files]\n",
    "features = merge_results(*data, label_col='ID')\n",
    "features.to_csv(save2, index=False)\n",
    "features"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "992c12c9",
   "metadata": {},
   "source": [
    "# 指定特征文件目录\n",
    "\n",
    "* save2： 修改成自己保存的特征目录\n",
    "* feature_dir：要融合的特征的特征文件目录，会融合所有的目录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e174c432",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from IPython.display import display\n",
    "os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'\n",
    "from onekey_algo import OnekeyDS as okds\n",
    "import pandas as pd\n",
    "from glob import glob\n",
    "from onekey_algo.custom.components.comp1 import normalize_df, merge_results\n",
    "\n",
    "os.makedirs('img', exist_ok=True)\n",
    "os.makedirs('results', exist_ok=True)\n",
    "os.makedirs('features', exist_ok=True)\n",
    "# 设置数据目录\n",
    "save2 = r'features/combined_features.csv'\n",
    "feature_dir = r'C:/Users/onekey/Desktop/f'\n",
    "data = [pd.read_csv(feature_file) for feature_file in glob(os.path.join(feature_dir, '*.csv'))]\n",
    "features = merge_results(*data, label_col='ID')\n",
    "features.to_csv(save2, index=False)\n",
    "features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f964b08",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
